var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AudioManager"),
    s = e("CommonHelper"),
    l = e("sdkConfig"),
    _ = e("AD"),
    c = e("MyInfoAndHeroViewUI"),
    d = e("TipViewUI"),
    h = cc._decorator,
    u = h.ccclass,
    p = h.property,
    m = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.game_mode_mask = null),
                (t.game_mode_view = null),
                (t.choose_game_mode = null),
                (t.shop_hd_node = null),
                (t.huodong_hd_node = null),
                (t.baozang_hd_node = null),
                (t.add_desk_node = null),
                (t.more_game_btn = null),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.initView = function () {
                e.prototype.initView.call(this),
                    (i.GlobalParams.JoinMatchGame = !1),
                    l.default.platform == l.EPlatform.VIVO
                        ? this.emitEvent(n.default.SEND_BOX_PORTAL_INFO, !0)
                        : (_.default.getInstance().hideBanner(), _.default.getInstance().showBanner()),
                    this.uiManager.showTopView(!0),
                    r.default.getInstance().setMusicVolume(0.5),
                    (i.GlobalParams.gameMusicName = "main_bgm"),
                    r.default.playGameBGM(),
                    (i.GlobalParams.PlayerJoinFight = !1),
                    (i.GlobalParams.MultiModeIndex = 0);
                var t = i.GlobalParams.LuckyBoxInfo.value,
                    o = i.GlobalParams.PlayerSigninInfo.value;
                i.GlobalParams.AgainGameInfo
                    ? ((i.GlobalParams.AgainGameInfo = !1), this.uiManager.showPopup("MatchViewUI"))
                    : t.open_today != new Date().toLocaleDateString() ||
                        o.signin_date != new Date().toLocaleDateString()
                        ? (this.uiManager.showPopup("ActivityViewUI"), (this.huodong_hd_node.active = !0))
                        : (this.huodong_hd_node.active = !1),
                    (this.shop_hd_node.active =
                        i.GlobalParams.PlayerInfo.value.free_coin != new Date().toLocaleDateString()),
                    (i.GlobalParams.ChangeGameMode = i.GlobalParams.PlayerInfo.value.change_mode),
                    this.showChooseGameModeInfo(),
                    this.showAddDeskInfo(),
                    this.showTaskRadDot(),
                    (i.GlobalParams.MathcTimeInfo = { time: 180, open: !0, name: "", head: 0 }),
                    l.default.platform == l.EPlatform.NO_AD
                        ? this.updateMatchTime()
                        : _.default.getInstance().getGameTestVersion() ||
                        i.GlobalParams.JoinGuideMode.value ||
                        this.updateMatchTime(),
                    (this.more_game_btn.active =
                        l.default.platform == l.EPlatform.OPPO && _.default.getInstance().getNavigateBoxPortalFlag());
            }),
            (t.prototype.update = function () {
                this.node.opacity = i.GlobalParams.JoinMatchGame ? 0 : 255;
            }),
            (t.prototype.updateMatchTime = function () {
                var e = this;
                i.GlobalParams.MathcTimeInfo.open &&
                    (i.GlobalParams.MathcTimeInfo.time--,
                        i.GlobalParams.MathcTimeInfo.time < 1 && this.uiManager.showPopup("MatchInvitationViewUI")),
                    this.scheduleOnce(function () {
                        e.updateMatchTime();
                    }, 1);
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(n.default.SEND_BOX_PORTAL_INFO, this.showBoxPortal, this),
                    this.attachEvent(n.default.SEND_UPDATE_TASK_INFO, this.showTaskRadDot, this),
                    this.attachEvent(n.default.SEND_ADD_DESK_ICON, this.showAddDeskInfo, this);
            }),
            (t.prototype.showAddDeskInfo = function () {
                var e = this;
                _.default.getInstance().desktopFlag(function (t) {
                    e.add_desk_node.active =
                        t == _.ResultEnum.Success &&
                        !i.GlobalParams.addDeskIcon.value &&
                        l.default.platform != l.EPlatform.TikTok;
                });
            }),
            (t.prototype.showTaskRadDot = function () {
                var e = i.GlobalParams.PlayerSeasonInfo.value,
                    t = i.GlobalParams.PlayerInfo.value;
                this.baozang_hd_node.active =
                    e.today_exp != new Date().toLocaleDateString() || t.level > e.free_award.length;
            }),
            (t.prototype.OnClick = function (t) {
                e.prototype.OnClick.call(this, t);
                var o = t.node.name;
                switch (o) {
                    case "my_hero_btn":
                        this.uiManager.showPopup("MyInfoAndHeroViewUI", function (e) {
                            e.getComponent(c.default).showChooseType(1);
                        });
                        break;
                    case "shop_btn":
                        (this.shop_hd_node.active = !1), this.uiManager.showPopup("ShopViewUI");
                        break;
                    case "tianfu_btn":
                        this.uiManager.showPopup("DSEViewUI");
                        break;
                    case "baozang_btn":
                        (this.baozang_hd_node.active = !1), this.uiManager.showPopup("StoreHouseViewUI");
                        break;
                    case "huodong_btn":
                        (this.huodong_hd_node.active = !1), this.uiManager.showPopup("ActivityViewUI");
                        break;
                    case "game_mode_btn":
                        this.game_mode_mask.active = !this.game_mode_mask.active;
                        break;
                    case "game_mode_mask":
                        this.game_mode_mask.active = !1;
                        break;
                    case "game_mode_0":
                    case "game_mode_1":
                    case "game_mode_2":
                    case "game_mode_3":
                        (i.GlobalParams.ChangeGameMode = s.default.getNameType(o, "game_mode_")),
                            this.showChooseGameModeInfo();
                        break;
                    case "start_game_btn":
                        (i.GlobalParams.MathcTimeInfo.open = !1), (i.GlobalParams.MathcTimeInfo.name = "");
                        var a = i.GlobalParams.PlayerInfo.value;
                        if (
                            ((a.change_mode = i.GlobalParams.ChangeGameMode),
                                (i.GlobalParams.PlayerInfo.value = a),
                                3 != i.GlobalParams.ChangeGameMode)
                        )
                            this.uiManager.showPopup("MatchViewUI");
                        else {
                            var n = i.GlobalParams.playerSkinInfo.value;
                            n.have_hero.length < 3
                                ? this.uiManager.showPopup("TipViewUI", function (e) {
                                    e.getComponent(d.default).showTipInfo(
                                        "当前拥有的英雄数不够3名英雄\n请获得3名英雄后再进行挑战\n当前拥有英雄数为：" +
                                        n.have_hero.length
                                    );
                                })
                                : ((i.GlobalParams.MultiModeIndex = 2), this.uiManager.showPopup("DungeonModeViewUI"));
                        }
                        this.game_mode_mask.active = !1;
                        break;
                    case "head_btn":
                        this.uiManager.showPopup("MyInfoAndHeroViewUI");
                        break;
                    case "setting_btn":
                        this.uiManager.showPopup("SettingViewUI");
                        break;
                    case "more_game":
                        _.default.getInstance().showNavigateBoxPortal();
                        break;
                    case "add_desk_btn":
                        this.uiManager.showPopup("DesktopPopup");
                }
            }),
            (t.prototype.showChooseGameModeInfo = function () {
                for (var e = 0; e < 4; e++)
                    (this.game_mode_view.children[e].getChildByName("light").active =
                        e == i.GlobalParams.ChangeGameMode),
                        e == i.GlobalParams.ChangeGameMode &&
                        (this.choose_game_mode.spriteFrame = this.game_mode_view.children[e]
                            .getChildByName("mode_type")
                            .getComponent(cc.Sprite).spriteFrame);
            }),
            (t.prototype.showBoxPortal = function (e, t) {
                t
                    ? l.default.platform == l.EPlatform.VIVO &&
                    _.default.getInstance().getNavigateBoxPortalFlag() &&
                    (_.default.getInstance().hideBanner(), _.default.getInstance().showNavigateBoxPortal())
                    : l.default.platform == l.EPlatform.VIVO &&
                    (_.default.getInstance().showBanner(), _.default.getInstance().hideNavigateBoxPortal());
            }),
            oo([p(cc.Node)], t.prototype, "game_mode_mask", void 0),
            oo([p(cc.Node)], t.prototype, "game_mode_view", void 0),
            oo([p(cc.Sprite)], t.prototype, "choose_game_mode", void 0),
            oo([p(cc.Node)], t.prototype, "shop_hd_node", void 0),
            oo([p(cc.Node)], t.prototype, "huodong_hd_node", void 0),
            oo([p(cc.Node)], t.prototype, "baozang_hd_node", void 0),
            oo([p(cc.Node)], t.prototype, "add_desk_node", void 0),
            oo([p(cc.Node)], t.prototype, "more_game_btn", void 0),
            oo([u], t)
        );
    })(a.default);
o.default = m;
